.TH std::moneypunct_byname 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::moneypunct_byname \- std::moneypunct_byname

.SH Synopsis
   Defined in header <locale>
   template< class CharT, bool Intl = false >
   class moneypunct_byname : public std::moneypunct<CharT, Intl>;

   std::moneypunct_byname is a std::moneypunct facet which encapsulates monetary
   formatting preferences of a locale specified at its construction.

.SH Specializations

   The standard library is guaranteed to provide every specialization that satisfies
   the following type requirements:

     * CharT is one of char and wchar_t, and
     * Intl is a possible specialization on a bool parameter.

.SH Member types

   Member type Definition
   pattern     std::money_base::pattern
   string_type std::basic_string<CharT>

.SH Member functions

   constructor   constructs a new moneypunct_byname facet
                 \fI(public member function)\fP
   destructor    destroys a moneypunct_byname facet
                 \fI(protected member function)\fP



std::moneypunct_byname::moneypunct_byname

   explicit moneypunct_byname( const char* name, std::size_t refs = 0 );
   explicit moneypunct_byname( const std::string& name, std::size_t refs  \fI(since C++11)\fP
   = 0 );

   Constructs a new std::moneypunct_byname facet for a locale with name.

   refs is used for resource management: if refs == 0, the implementation destroys the
   facet, when the last std::locale object holding it is destroyed. Otherwise, the
   object is not destroyed.

.SH Parameters

   name - the name of the locale
   refs - the number of references that link to the facet



std::moneypunct_byname::~moneypunct_byname

   protected:
   ~moneypunct_byname();

   Destroys the facet.



Inherited from std::moneypunct

.SH Member types

   Member type Definition
   char_type   CharT
   string_type std::basic_string<CharT>

.SH Member functions

                 invokes do_decimal_point
   decimal_point \fI(public member function of std::moneypunct<CharT,International>)\fP

                 invokes do_thousands_sep
   thousands_sep \fI(public member function of std::moneypunct<CharT,International>)\fP

                 invokes do_grouping
   grouping      \fI(public member function of std::moneypunct<CharT,International>)\fP

                 invokes do_curr_symbol
   curr_symbol   \fI(public member function of std::moneypunct<CharT,International>)\fP

   positive_sign invokes do_positive_sign or do_negative_sign
   negative_sign \fI(public member function of std::moneypunct<CharT,International>)\fP

                 invokes do_frac_digits
   frac_digits   \fI(public member function of std::moneypunct<CharT,International>)\fP

   pos_format    invokes do_pos_format/do_neg_format
   neg_format    \fI(public member function of std::moneypunct<CharT,International>)\fP


.SH Protected member functions

   do_decimal_point provides the character to use as decimal point
   \fB[virtual]\fP        \fI\fI(virtual protected member function\fP of\fP
                    std::moneypunct<CharT,International>)
   do_thousands_sep provides the character to use as thousands separator
   \fB[virtual]\fP        \fI\fI(virtual protected member function\fP of\fP
                    std::moneypunct<CharT,International>)
                    provides the numbers of digits between each pair of thousands
   do_grouping      separators
   \fB[virtual]\fP        \fI\fI(virtual protected member function\fP of\fP
                    std::moneypunct<CharT,International>)
   do_curr_symbol   provides the string to use as the currency identifier
   \fB[virtual]\fP        \fI\fI(virtual protected member function\fP of\fP
                    std::moneypunct<CharT,International>)
   do_positive_sign provides the string to indicate a positive or negative value
   do_negative_sign \fI\fI(virtual protected member function\fP of\fP
   \fB[virtual]\fP        std::moneypunct<CharT,International>)
   do_frac_digits   provides the number of digits to display after the decimal point
   \fB[virtual]\fP        \fI\fI(virtual protected member function\fP of\fP
                    std::moneypunct<CharT,International>)
   do_pos_format    provides the formatting pattern for currency values
   do_neg_format    \fI\fI(virtual protected member function\fP of\fP
   \fB[virtual]\fP        std::moneypunct<CharT,International>)

.SH Member constants

   Member                   Definition
   const bool intl (static) International

.SH Member objects

   static std::locale::id id id of the locale
                             \fI(public member object)\fP



Inherited from std::money_base

   Member type                                     Definition
   enum part { none, space, symbol, sign, value }; unscoped enumeration type
   struct pattern { char field[4]; };              the monetary format type

   Enumeration constant Definition
   none                 whitespace is permitted but not required except in the last
                        position, where whitespace is not permitted
   space                one or more whitespace characters are required
   symbol               the sequence of characters returned by
                        std::moneypunct::curr_symbol is required
                        the first of the characters returned by
   sign                 std::moneypunct::positive_sign or
                        std::moneypunct::negative_sign is required
   value                the absolute numeric monetary value is required

.SH Example

   This example demonstrates how to apply monetary formatting rules of another language
   without changing the rest of the locale.


// Run this code

 #include <iomanip>
 #include <iostream>
 #include <locale>

 int main()
 {
     long double mon = 1234567;
     std::locale::global(std::locale("en_US.utf8"));
     std::wcout.imbue(std::locale());
     std::wcout << L"american locale: " << std::showbase
                << std::put_money(mon) << '\\n';
     std::wcout.imbue(std::locale(std::wcout.getloc(),
                                  new std::moneypunct_byname<wchar_t>("ru_RU.utf8")));
     std::wcout << L"american locale with russian moneypunct: "
                << std::put_money(mon) << '\\n';
 }

.SH Output:

 american locale: $12,345.67
 american locale with russian moneypunct: 12 345.67 руб

.SH See also

              defines monetary formatting parameters used by std::money_get and
   moneypunct std::money_put
              \fI(class template)\fP
